<?php

class WrIssuePeer extends BaseWrIssuePeer
{
  public static function getBySynopsis($issueId, $synopsis)
  {
    $conn = Propel::getConnection();
    if ($issueId == 0) {
      $query = 'SELECT m.name, b.date1, i.comment, i.hour
        FROM wr_basic b, wr_issue i, wr_member m
        WHERE i.issue_id = %s AND i.synopsis = "%s"
        AND i.basic_id = b.id
        AND b.member_id = m.id order by b.date1 asc';
      $query = sprintf($query, $issueId, $synopsis);
    } else {
      $query = 'SELECT m.name, b.date1, i.comment, i.hour
        FROM wr_basic b, wr_issue i, wr_member m
        WHERE i.issue_id = %s
        AND i.basic_id = b.id
        AND b.member_id = m.id order by b.date1 asc';
      $query = sprintf($query, $issueId);
    }
    
    $stmt = $conn->prepare($query);
    $stmt->execute();
    $issues = $stmt->fetchAll(PDO::FETCH_ASSOC);
    return $issues;
    
  }
}
